import java.util.ArrayList;
import java.util.List;

public class Solution {
    List<Integer> path;
    List<List<Integer>> ret;
    public List<List<Integer>> subsets(int[] nums) {
        path = new ArrayList<>();
        ret = new ArrayList<>();

        dfs(nums, 0);

        return ret;
    }

    private void dfs(int[] nums, int pos) {

        ret.add(new ArrayList<>(path));
        for (int i = pos; i < nums.length; i++) {
            path.add(nums[i]);
            dfs(nums, i+1);
            path.remove(path.size() - 1);
        }
    }
}
